package com.briup.estore.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.briup.estore.common.utils.PageUtils;
import com.briup.estore.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import com.briup.estore.entity.ShopEntity;
import com.briup.estore.service.ShopService;


/**
 * @author adam
 * @email xueyz@briup.com
 * @date 2023-03-30 14:35:49
 */
@Controller
public class ShopController {
    @Autowired
    private ShopService shopService;


    /**
     * 信息
     */
    @GetMapping("/toViewShop")
    public String info(Long shopId, Model model) {
        ShopEntity shop = shopService.getById(shopId);
        model.addAttribute("shop", shop);
        return "viewShop";
    }

    @GetMapping("searchShop")
    public String searchShop(String shopName, Model model) {
        List<ShopEntity> list = shopService.findContainsName(shopName);
        model.addAttribute("shopList", list);
        return "list";
    }

    @GetMapping("toList")
    public String toList(Long categoryId, Model model) {
        List<ShopEntity> list = shopService.findByCategoryId(categoryId);
        model.addAttribute("shopList", list);
        return "list";
    }




}
